﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;

namespace HYRevitCode.ShortPathSuite
{
	public class ShortDistanceCalculater
	{
		public List<XYZ> CalculateShortPath(XYZ startPoint, XYZ endPoint, List<Curve> allRunWay)
		{
			List<XYZ> result = null;
			this.m_thisGraph = new UndirectGraph();
			foreach (Curve curve in allRunWay)
			{
				this.m_thisGraph.AddEdge(curve.GetEndPoint(0), curve.GetEndPoint(1), null);
			}
			this.m_shortPath = new ShortestPath(this.m_thisGraph);
			List<ElementId> list;
			if (this.m_shortPath.RouteShortestPath(startPoint, endPoint, out list, out result) == RouteResult.eOK)
			{
				return result;
			}
			return null;
		}

		private UndirectGraph m_thisGraph;

		private ShortestPath m_shortPath;
	}
}
